package foliotracker.tests;

import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;

import foliotracker.IStockPriceService;
import foliotracker.StockPriceServiceException;
import foliotracker.UnknownStockSymbolException;
import foliotracker.YahooStockPriceService;

public class YahooStockPriceServiceTest
{
	private IStockPriceService service;
	
	@Before
	public void setup()
	{
		service = new YahooStockPriceService();
	}
	
	@Test
	public void getStockPriceTest() throws UnknownStockSymbolException, StockPriceServiceException
	{
		double price = service.getStockPrice("MSFT");
		//can't really check the price, but hopefully there wasn't an exception
	}
	
	@Test(expected = UnknownStockSymbolException.class)
	public void getStockPriceInvalidTest() throws UnknownStockSymbolException, StockPriceServiceException
	{
		double price = service.getStockPrice("XXXX");
	}
	
	@Test
	public void getStockNameTest() throws UnknownStockSymbolException, StockPriceServiceException
	{
		String name = service.getStockName("AAPL");
		assertEquals("Apple Inc", name);
	}
	
	@Test(expected = UnknownStockSymbolException.class)
	public void getStockNameInvalidTest() throws UnknownStockSymbolException, StockPriceServiceException
	{
		String name = service.getStockName("XXXX");
	}

}
